package io.renren.config;

import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;


import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;

/**   
 * Description: 日期转换 - "yyyy-MM-dd HH:mm:ss"   
 * Author: liuzh   
 * Update: liuzh(2014-04-17 10:59)   
 */    
public class DateYMDHMSJsonDeserializer extends JsonDeserializer<Date> {    
	private static SimpleDateFormat sdf= new SimpleDateFormat("yyyy-MM-dd");
    @Override    
    public Date deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException {    
        try {    
            return sdf.parse(jp.getText());
        } catch (Exception e) {    
            return new Date(jp.getLongValue());    
        }    
    }    
} 